package org.apache.flink.runtime.rest.handler.cluster;

import java.io.File;
import java.util.Map;

import javax.annotation.Nullable;

import org.apache.flink.api.common.time.Time;
import org.apache.flink.runtime.rest.handler.HandlerRequest;
import org.apache.flink.runtime.rest.messages.EmptyMessageParameters;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders;
import org.apache.flink.runtime.rpc.retriever.GatewayRetriever;
import org.apache.flink.runtime.webmonitor.RestfulGateway;

/** Rest handler which serves the log files from ConsumerManager. */
public class ConsumerManagerLogFileHandler
        extends AbstractConsumerManagerFileHandler<EmptyMessageParameters> {

    private final File file;

    public ConsumerManagerLogFileHandler(
            GatewayRetriever<? extends RestfulGateway> leaderRetriever,
            Time timeout,
            Map<String, String> responseHeaders,
            UntypedResponseMessageHeaders<EmptyRequestBody, EmptyMessageParameters> messageHeaders,
            @Nullable File file) {
        super(leaderRetriever, timeout, responseHeaders, messageHeaders);

        this.file = file;
    }

    @Override
    protected File getFile(HandlerRequest<EmptyRequestBody> handlerRequest) {
        return file;
    }
}
